package com.zhaoyang.test.druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author 赵扬
 * @time 2020/4/27 08:05
 */
public class DruidDemo01 {

    public static void main(String[] args) throws Exception {
        // 加载配置文件
        Properties properties = new Properties();
        InputStream is = DruidDemo01.class.getClassLoader().getResourceAsStream("druid.properties");
        properties.load(is);

        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        for (int i = 1; i <= 5000; i++) {
            Connection connection = dataSource.getConnection();
            System.out.println(i + "-> " + connection);
        }
    }
}
